# pylint: disable-msg=C0103,W0622,E1101
"""
@author: Sergiy Tsymbalyuk
"""

import logging

from pylons import request, response, session, tmpl_context as c, url
from pylons.i18n import lazy_ugettext as _

from sqlalchemy import func

from chowa.model import District
from chowa.lib.site.navigation import Tab

from pubservices.lib.base import render, Session
from pubservices.lib.base import PublicServicesController

log = logging.getLogger(__name__)

class CommunicationsController(PublicServicesController):
    __primary_tabs__ = [
        [
            Tab(params=dict(action='index'),
                ignore_params=['analytics',],
                caption=_('Districts'),
                description=_('Districts')
            ),
            Tab(params=dict(action='analysis', service='phone', default__analytics='period'),
                caption=_('Phone'),
                description=_('Phone')
            ),
            Tab(params=dict(action='analysis', service='long_distance', default__analytics='period'),
                caption=_('Long distance'),
                description=_('Long distance')
            ),
            Tab(params=dict(action='analysis', service='various', default__analytics='period'),
                caption=_('Various'),
                description=_('Various')
            ),
        ],
        [
            Tab(params=dict(default__action='total', service='phone'),
                caption=_('Phone'),
                description=_('Phone')
            ),
            Tab(params=dict(default__action='total', service='long_distance'),
                caption=_('Long distance'),
                description=_('Long distance')
            ),
            Tab(params=dict(default__action='total', service='various'),
                caption=_('Various'),
                description=_('Various')
            ),
        ]
    ]
    
    def __init__(self):
        c.main_heading = _('Communications')

    def index(self):
        c.districts = Session.query(District).all()
        return render('/communications/index.html')
    
    def _analysis_c11ns(self, service):
        return render('/communications/analysis.html')
